import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { GroupBuyVO, GroupBuyForm, GroupBuyQuery } from '@/api/tearoom/groupBuy/types';

/**
 * 查询团购核销列表
 * @param query
 * @returns {*}
 */

export const listGroupBuy = (query?: GroupBuyQuery): AxiosPromise<GroupBuyVO[]> => {
  return request({
    url: '/tearoom/groupBuy/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询团购核销详细
 * @param id
 */
export const getGroupBuy = (id: string | number): AxiosPromise<GroupBuyVO> => {
  return request({
    url: '/tearoom/groupBuy/' + id,
    method: 'get'
  });
};

/**
 * 新增团购核销
 * @param data
 */
export const addGroupBuy = (data: GroupBuyForm) => {
  return request({
    url: '/tearoom/groupBuy',
    method: 'post',
    data: data
  });
};

/**
 * 修改团购核销
 * @param data
 */
export const updateGroupBuy = (data: GroupBuyForm) => {
  return request({
    url: '/tearoom/groupBuy',
    method: 'put',
    data: data
  });
};

/**
 * 删除团购核销
 * @param id
 */
export const delGroupBuy = (id: string | number | Array<string | number>) => {
  return request({
    url: '/tearoom/groupBuy/' + id,
    method: 'delete'
  });
};
